package com.dnjn.happiness.common.security.utils;

import com.dnjn.happiness.common.security.utils.SecurityUtils;
import com.dnjn.happiness.system.api.domain.SysRole;
import com.dnjn.happiness.system.api.model.LoginUser;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Set;

public class VerifyUtil {
    /**
     * 判断当前登录用户是否包含admin(超级管理员) | admin_hq(总部管理员)
     */


    public static Boolean whetherAllPermissions() {
        Boolean flag = false;
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (null != loginUser) {
            Set<String> roles = loginUser.getRoles();
            if (!CollectionUtils.isEmpty(roles)) {
                for (String role : roles) {
                    if ("admin".equals(role) || "admin_hq".equals(role)) {
                        flag = true;
                    }
                }
            } else {
                if (1L == loginUser.getUserid()) {
                    flag = true;
                }
            }
        }
        return flag;
    }
}
